package com.hanbang.taitaigou.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by Administrator on 2016/1/21.
 */
public class BaseViewHolder extends RecyclerView.ViewHolder {
    public BaseViewHolder(final View itemView, final OnItemClickListent onItemClickListent) {
        super(itemView);
        /**
         * 设置点击事件
         */
        if (onItemClickListent != null) {
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (onItemClickListent != null) {
                        if (getAdapterPosition() >= 0) {
                            onItemClickListent.onItemClick(itemView, getAdapterPosition(), getItemViewType(), getItemId());
                        }

                    }
                }
            });
        }
    }

    public interface OnItemClickListent {
        void onItemClick(View view, int position, int viewType, long id);
    }
}
